<?php

class ArticlesController extends Zend_Controller_Action
{

    public function init()
    {
        
		$this->base_url = $this->getRequest()->getBaseUrl();
		
    }

    public function indexAction()
    {
        // action body
		
		//$form_article=new Application_Form_Installer(null, '');
		//$this->view->form_installer=$form_installer;

		/*$adapter_article=new Application_Model_DbTable_Article();
		
		$select = $adapter_article->select();
		
		$this->view->tab_all_article = $adapter_article->fetchAll($select)->toArray();
		*/
		
		//$form_article=new Application_Form_Article(null, $this->base_url);
		//$this->view->form_article = $form_article;
		//$this->view->base_url = $this->base_url;
		
		
    }
	
	public function affaddAction()
	{
		odcf_debug::debug("add article");
		
		$this->_helper->layout->disableLayout();
		
		
		$form_article=new Application_Form_Article(null, $this->base_url);
		
		$this->view->form_article = $form_article;
		
	}

	public function validaddAction()
	{
		odcf_debug::debug("valid add article");
		
		$this->_helper->layout->disableLayout();
		//$this->_helper->viewRenderer->setNoRender();
	
		
		$form_article=new Application_Form_Article(null, $this->base_url);
		
		//odcf_debug::debug($_POST);
		
		//odcf_debug::debug($form_article->isValid($_POST)); //PC je pensais que c'etait necessaire avant processAjax,mais non
		if ($form_article->isValid($_POST))
		{
			$this->view->form_valide=true;
		} else {
			$this->view->form_valide=false;
			$this->view->form_messages=$form_article->getMessages();
		}
		
		//odcf_debug::debug($form_article->getErrors());
		//odcf_debug::debug($form_article->getMessages());
		
		
		
		//odcf_debug::debug($form_article->getErrors());
		//odcf_debug::debug($form_article->getMessages());
		
		//$this->view->form_article = $form_article;
		
		
		
	}
	
	public function affmodifAction()
	{
		odcf_debug::debug("modif article");
		
		$form_article=new Application_Form_Article(null, $this->base_url);
		$this->view->form_article = $form_article;
		
	}


}

